<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt_rt" %>

<html>
<head>
    <title>登录页</title>
    <%--echart线图、柱状图、饼图等各种图型库 cdn--%>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js"></script>
    <%--jquery cdn--%>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.1/jquery.js"></script>
</head>
<body>
${error}
<form action="/login.do">
        <input type="hidden" id="uuid" name="uuid">
    手机号<input name="phone"><br>

    短信验证码<input name="smsCode"> <input type="button" onclick="sendMsg()" value="发送验证码"><br>
    密码<input name="password"><br>
    图片验证码 <input name="picCode"><img  id="img" src="" onclick="initPic()"><br>
    <input type="submit" value="登录"><br>


</form>
</body>
<script>
    var uuid = guid();
    initPic()



    function sendMsg() {
        let phone = $('[name=phone]').val();

        $.ajax({
            url:'/sendMsg.do?phone=' + phone,
            success:function (data) {
                if (data){
                    alert("发送成功")
                }
            }
        })
    }
    function initPic() {
        document.getElementById("img").src= '/picCode.do?uuid='+ uuid +'&time=' + new Date().getTime()
        document.getElementById("uuid").value = uuid
    }

    function guid() {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
            var r = Math.random() * 16 | 0,
                v = c == 'x' ? r : (r & 0x3 | 0x8);
            return v.toString(16);
        });
    }
</script>
</html>